home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11495 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: rcp6.elan.af.mil!rscernix!danpop
  2. From: danpop@mail.cern.ch (Dan Pop)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: is getopt() ANSI and portable ?
  5. Date: 21 Mar 96 19:45:58 GMT
  6. Organization: CERN European Lab for Particle Physics
  7. Message-ID: <danpop.827437558@rscernix>
  8. References: <31512EC7.389F@eso.org>
  9. NNTP-Posting-Host: ues5.cern.ch
  10. X-Newsreader: NN version 6.5.0 #7 (NOV)
  11.  
  12. In <31512EC7.389F@eso.org> Nicolas Devillard <nDevil@eso.org> writes:
  13.  
  14. >I do not want to reinvent the wheel by creating again my own
  15. >command line parser. I found this getopt() function being part
  16. >of stdlib, but I'd like to know:
  17. >
  18. >1. If it is part of the ANSI C stdlib ?
  19.  
  20. It isn't.
  21.  
  22. >2. If it is a portable call ?
  23.  
  24. It can be implemented portably in ANSI C.  Ask your archie client to
  25. find an implementation.
  26.  
  27. >I cannot find it in the POSIX prog guide.
  28.  
  29. This is your problem.  My man page says:
  30.  
  31.  STANDARDS CONFORMANCE
  32.       getopt(): AES, SVID2, XPG2, XPG3, XPG4, POSIX.2
  33.  
  34. >The definition as given by my man page says :
  35. >
  36. >SYNOPSIS
  37. >     #include <stdlib.h>
  38. >
  39. >     int getopt(int argc, char * const *argv,
  40. >          const char *optstring);
  41.  
  42. getopt() is not a standard C function, hence it doesn't belong to
  43. <stdlib.h>.  However, some vendors stupidly require/recommend the
  44. inclusion of <stdlib.h> or even <stdio.h>.  Most of them declare it in
  45. <unistd.h>, where it actually belongs.
  46.  
  47. Dan
  48. --
  49. Dan Pop
  50. CERN, CN Division
  51. Email: danpop@mail.cern.ch 
  52. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  53.